package cn.dengta.webapp.im.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.BaseEntity;
import cn.dengta.webapp.user.model.Gender;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

/**
 * 用户登录日统计
 *
 * @author lgy
 * @since 2022-12-07
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("im_ws_user_login_daily_log")
public class WsUserLoginDailyLog extends BaseEntity {

	/** 用户ID */
	Long userId;
	/** 性别 */
	Gender gender;
	/** 登录时间 */
	Date loginTime;
	/** 最后登出时间 */
	Date logoutTime;
	/** 登录时长 */
	Long duration;
	/** 统计时间 */
	Date reportTime;

	public WsUserLoginDailyLog init(Long userId, Gender gender, Date loginTime, Date logoutTime, Long duration, Date reportTime, Date now) {
		this.userId = userId;
		this.gender = gender;
		this.loginTime = X.expectNotNull(loginTime, now);
		this.logoutTime = X.expectNotNull(logoutTime, now);
		this.duration = duration;
		this.reportTime = reportTime;
		return this;
	}

	public static final String USER_ID = "user_id";
	public static final String GENDER = "gender";
	public static final String LOGIN_TIME = "login_time";
	public static final String LOGOUT_TIME = "logout_time";
	public static final String DURATION = "duration";
	public static final String REPORT_TIME = "report_time";

}
